import { Row, Col } from 'antd';
import { connect } from 'dva';
import React from 'react';

import DayPosWarn from './DayPosWarn';
import ProductWarn from './ProductWarn';
import ResaleWarn from './ResaleWarn';

class InfoWran extends React.Component {
  // eslint-disable-next-line no-useless-constructor
  constructor() {
    super();
  }

  handleUserMenu = (menus, tabControl) => {
    if (menus.length) {
      if (menus.some((item) => item.name == '其它')) {
        // eslint-disable-next-line no-plusplus
        for (let i = 0; i < menus.length; i++) {
          if (menus[i].name == '其它') {
            return menus[i]?.menuModels.some((item) => item.name == tabControl);
          }
        }
      }
    }
  };

  render() {
    const {
      user: { userMenuData },
    } = this.props;
    return (
      <div>
        <Row gutter={16}>
          {this.handleUserMenu(userMenuData, '回售登记提醒') ? (
            <Col span={8}>
              <ResaleWarn />
            </Col>
          ) : (
            ''
          )}
          <Col span={this.handleUserMenu(userMenuData, '回售登记提醒') ? 8 : 12}>
            <DayPosWarn />
          </Col>
          <Col span={this.handleUserMenu(userMenuData, '回售登记提醒') ? 8 : 12}>
            <ProductWarn />
          </Col>
        </Row>
      </div>
    );
  }
}
export default connect(({ userM: user, OperatePlatformM }) => ({ user, OperatePlatformM }))(InfoWran);
